<template>
    <div>
        <a-modal
         v-model:visible="visible" 
         :title="formState.id?'编辑（企业名称：'+information.fqymc+'）':'新增--（企业名称：'+information.fqymc+'）'" 
         :width="660"
         :footer="null"
         >
            <div v-if="visible">
                <a-form :form="form">
                    <a-form-item label="违法内容">
                        <a-textarea 
                            placeholder="请输入违法内容"
                            v-model:value="formState.fwfnr"
                            :autosize="{ minRows: 3, maxRows: 10000 }"
                            v-decorator="['fwfnr', { initialValue:formState.fwfnr, rules: rules.fwfnr}]"
                        ></a-textarea>
                    </a-form-item>
                    <a-form-item label="备注">
                        <a-textarea 
                            placeholder="请输入违法内容"
                            v-model:value="formState.fbz"
                            :autosize="{ minRows: 3, maxRows: 10000 }"
                        ></a-textarea>
                    </a-form-item>
                </a-form>
            </div>
            <div style="display: flex;justify-content: flex-end;margin-top: 20px;">
                <a-button @click="visible = false">取消</a-button>
                <a-button style="margin: 0 20px;" class="blue-btn" type="primary" @click="handleOk(true)">保存</a-button>
                <a-button class="blue-btn" type="primary" @click="handleOk(false)">保存并关闭</a-button>
            </div>
        </a-modal>
    </div>
</template>
<script>
import { addQyWfwjjl, updateWfwjjl, } from './service/index'
export default {
    components:{

    },
    props:{

    },
    data(){
        return{
            visible:false,
            formState:{},
            information:{},
            form: this.$form.createForm(this, { name: 'coordinated' }),
            rules:{
                fwfnr: [{
                    required: true,
                    message: '请输入违法内容',
                    trigger: 'blur',
                }],
            },
        }
    },
    watch:{

    },
    mounted(){
        
    },
    methods:{
        getData(info,val){
            this.formState = val
            this.information = info
        },
        handleOk(val){
            let data = {
                ...this.formState,
                fqyid:this.information.id
            }
            if(this.formState.id){
                updateWfwjjl(data).then(res=>{
                    if(res.code == 200){
                        this.visible = val
                        this.$emit('successClick',this.formState)
                        this.$message.success(res.message)
                    }else{
                        this.$message.warning(res.message)
                    }
                })
            }else{
                addQyWfwjjl(data).then(res=>{
                    if(res.code == 200){
                        this.formState.id = res.result.id
                        this.visible = val
                        this.$emit('successClick',this.formState)
                        this.$message.success(res.message)
                    }else{
                        this.$message.warning(res.message)
                    }
                })
            }
            

        }
    }
}
</script>